package com.twl.app.base.bo;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.twl.app.base.entity.Bfsalary;
import com.twl.app.base.entity.Companyb;
import com.twl.app.base.entity.Dispatchmanger;
import com.twl.app.base.entity.Dutyback;
import com.twl.app.base.entity.Dutycount;
import com.twl.app.base.entity.Dutydeduct;
import com.twl.app.base.entity.Dutymeals;
import com.twl.app.base.entity.Dutymoney;
import com.twl.app.base.entity.Dutysendmoney;
import com.twl.app.base.entity.Jsbfmoney;
import com.twl.app.base.entity.Leavebmoney;
import com.twl.app.base.entity.Loyalward;
import com.twl.app.base.entity.MinMoney;
import com.twl.app.base.entity.Miniwase;
import com.twl.app.base.entity.Moneyadjust;
import com.twl.app.base.entity.Overtimemeals;
import com.twl.app.base.entity.Overtimemoney;
import com.twl.app.base.entity.Personalduty;
import com.twl.app.base.entity.Personalmoney;
import com.twl.app.base.entity.SalSalaryData;
import com.twl.app.base.entity.SalSocialAdjust;
import com.twl.app.base.entity.Secureunit;
import com.twl.app.base.entity.Shiftallowance;
import com.twl.app.base.entity.Solidmoney;
import com.twl.app.base.entity.Tradecost;
import com.twl.app.base.util.CryptUtils;
import com.twl.app.base.util.NotNullBeanUtils;
import com.twl.app.base.vo.Pagevo;
import com.twl.app.base.vo.RequestVo;
import com.twl.app.base.vo.Salarydetail;
import com.twl.common.constant.SalConstant;
import com.twl.core.framework.bo.impl.AbsCrudBoImpl;
import com.twl.core.framework.dao.WSHibernateDaoSupportProxy;
import com.twl.core.framework.page.Page;
import com.twl.core.framework.util.ContextContainer;

@Transactional
@Repository(value = "dutyservicedao")
public class Dutyservicedao extends AbsCrudBoImpl {

	private Logger logger = Logger.getLogger(Dutyservicedao.class);
	@Autowired
	private WSHibernateDaoSupportProxy wsHibernateDaoSupportProxy;

	/**
	 * 增加税前工资
	 */
	public String savedutymoney(Dutymoney m) {

		Object fr = null;
		try {
			String sql = "from Dutymoney where staffint='" + m.getStaffint()
					+ "' and datemoney='" + m.getDatemoney() + "'";
			Dutymoney dbResult = (Dutymoney) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult!= null) {
				 
				NotNullBeanUtils.copyProperties(dbResult,m);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Dutymoney duty=(m);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}

		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/**
	 * 个人保险金
	 * 
	 * @return
	 */
	public String savepersonalmoney(Personalmoney m,int j) {

		Object fr = null;
		try {
		 
				String sql = "from Personalmoney where staffint='"
						+ m.getStaffint() + "' and datemoney='" + m.getDatemoney()
						+ "' and persontype='"+j+"'";
				Personalmoney dbResult = (Personalmoney) wsHibernateDaoSupportProxy
						.uniqueResult(sql);
				if (dbResult != null) {
					Personalmoney duty=(m);
					NotNullBeanUtils.copyProperties(dbResult,duty);
					wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
				} else {
					Personalmoney duty=(m);
					wsHibernateDaoSupportProxy.saveOrUpdate(duty);
				}
			
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/**
	 * 增加税前扣除
	 * 
	 * @param ct
	 * @return
	 */
	public String savedutydeduct(Dutydeduct ct) {
		Object fr = null;
		try {
			String sql = "from Dutydeduct where staffint='" + ct.getStaffint()
					+ "' and datemoney='" + ct.getDatemoney() + "'";

			Dutydeduct dbResult = (Dutydeduct) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				Dutydeduct duty=(ct);
				NotNullBeanUtils.copyProperties(dbResult, duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Dutydeduct duty=(ct);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/**
	 * 增加税前应发
	 * 
	 * @param ct
	 * @return
	 */
	public String savedutysendmoney(Dutysendmoney ct) {

		Object fr = null;
		try {
			String sql = "from Dutysendmoney where staffint='"
					+ ct.getStaffint() + "' and datemoney='"
					+ ct.getDatemoney() + "'";

			Dutysendmoney dbResult = (Dutysendmoney) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				Dutysendmoney duty=(ct);
				NotNullBeanUtils.copyProperties(dbResult, duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Dutysendmoney duty=(ct);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/**
	 * 增加工会费
	 * 
	 * @return
	 */
	public String savetradecost(Tradecost ct) {

		Object fr = null;
		try {
			String sql = "from Tradecost where staffint='" + ct.getStaffint()
					+ "' and datemoney='" + ct.getDatemoney() + "'";

			Tradecost dbResult = (Tradecost) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				Tradecost duty=(ct);
				NotNullBeanUtils.copyProperties(dbResult, duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Tradecost duty=(ct);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/***
	 * 税后饭贴
	 * 
	 * @param back
	 * @return
	 */
	public String saveDutyback(Dutyback back) {

		Object fr = null;
		try {
			String sql = "from Dutyback where staffint='" + back.getStaffint()
					+ "' and datemoney='" + back.getDatemoney() + "'";

			Dutyback dbResult = (Dutyback) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				Dutyback duty=(back);
				NotNullBeanUtils.copyProperties(dbResult,duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Dutyback duty=(back);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/**
	 * 增加个人所得税
	 * 
	 * @param du
	 * @return
	 */
	public String savepersonalduty(Personalduty du) {
           
		Object fr = null;
		try {
			 
			String sql = "from Personalduty where staffint='"
					+ du.getStaffint() + "' and datemoney='"
					+ du.getDatemoney() + "'";

			Personalduty dbResult = (Personalduty) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				Personalduty duty=(du);
				NotNullBeanUtils.copyProperties(dbResult, duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Personalduty duty=(du);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/***
	 * 增加税后应发合计
	 * 
	 * @param cut
	 * @return
	 */
	public String savedutycount(Dutycount cut) {
		Object fr = null;
		try {
			String sql = "from Dutycount where staffint='" + cut.getStaffint()
					+ "' and datemoney='" + cut.getDatemoney() + "'";

			Dutycount dbResult = (Dutycount) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				Dutycount duty=(cut);
				NotNullBeanUtils.copyProperties(dbResult, duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Dutycount duty=(cut);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/***
	 * 增加实发工资
	 * 
	 * @param mo
	 * @return
	 */
	public String savesolidmoney(Solidmoney mo) {

		Object fr = null;
		try {
			String sql = "from Solidmoney where staffint='" + mo.getStaffint()
					+ "' and datemoney='" + mo.getDatemoney() + "'";

			Solidmoney dbResult = (Solidmoney) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				Solidmoney duty=(mo);
				NotNullBeanUtils.copyProperties(dbResult, duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Solidmoney duty=(mo);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/**
	 * 增加单位保险金
	 * 
	 * @param it
	 * @return
	 */
	public String savesecureunit(Secureunit it,int j) {
		Object fr = null;
		try {
	 
				String sql = "from Secureunit where staffint='" + it.getStaffint()
						+ "' and datemoney='" + it.getDatemoney() + "' and judgeint="+j+"";

				Secureunit dbResult = (Secureunit) wsHibernateDaoSupportProxy
						.uniqueResult(sql);
				if (dbResult != null) {
					Secureunit duty=(it);
					NotNullBeanUtils.copyProperties(dbResult, duty);
					wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
				} else {
					Secureunit duty=(it);
					wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/**
	 * 增加派遣员工管理费
	 * 
	 * @param der
	 * @return
	 */
	public String savedispatchmanger(Dispatchmanger der) {
		Object fr = null;
		try {
			String sql = "from Dispatchmanger where staffint='"
					+ der.getStaffint() + "' and datemoney='"
					+ der.getDatemoney() + "'";

			Dispatchmanger dbResult = (Dispatchmanger) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				Dispatchmanger duty=(der);
				NotNullBeanUtils.copyProperties(dbResult, duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Dispatchmanger duty=(der);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	public String saveminomey(MinMoney me) {
		Object fr = null;
		try {
			String sql = "from MinMoney where staffint='" + me.getStaffint()
					+ "' and datemoney='" + me.getDatemoney() + "'";

			MinMoney dbResult = (MinMoney) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				MinMoney duty=(me);
				NotNullBeanUtils.copyProperties(dbResult, duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				MinMoney duty=(me);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			 
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/***
	 * 增加税前饭贴
	 * 
	 * @param ls
	 * @return
	 */
	public String savedutymeals(Dutymeals ls) {
		Object fr = null;
		try {
			String sql = "from Dutymeals where staffint='" + ls.getStaffint()
					+ "' and datemoney='" + ls.getDatemoney() + "'";

			Dutymeals dbResult = (Dutymeals) wsHibernateDaoSupportProxy
					.uniqueResult(sql);
			if (dbResult != null) {
				Dutymeals duty=(ls);
				NotNullBeanUtils.copyProperties(dbResult, duty);
				wsHibernateDaoSupportProxy.saveOrUpdate(dbResult);
			} else {
				Dutymeals duty=(ls);
				wsHibernateDaoSupportProxy.saveOrUpdate(duty);
			}
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}

	/***
	 * 增加最低工资基数表
	 * 
	 * @param se
	 * @return
	 */
	public String saveminiwase(Miniwase se) {
		Object fr = null;
		try {
			fr=super.addData(se);
		} catch (Exception e) {
			log.fatal("---------------增加出错");
			e.printStackTrace();
		}
		if (fr != null) {
			return "YES";
		} else {
			return "NO";
		}
	}
    
	/**
	 * 查询个人保险金
	 * 
	 * @param id
	 * @return
	 */
	public List<Personalmoney> findperson(String id) {
		String hql = "from Personalmoney as s where s.staffint='" + id + "'";
		@SuppressWarnings("unchecked")
		List<Personalmoney> m = super.findAll(hql);
		List<Personalmoney> list=null ;
		try {
			if(m.size()>0){
				list=CryptUtils.decryptNew(m);
				//list= m;
			}else{
				return m;
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
	public List<Personalmoney> findperson(String id,String date) {
		String hql = "from Personalmoney as s where s.staffint='" + id + "' and s.datemoney='"+date+"'";
		@SuppressWarnings("unchecked")
		List<Personalmoney> m = super.findAll(hql);
		List<Personalmoney> list=null ;
		try {
			if(m.size()>0){
				 list= CryptUtils.decryptNew(m);
				///list=m;
			}else{
				return m;
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
	/**
	 * 查询请假扣款
	 * 
	 * @param id
	 * @return
	 */
	public List<Leavebmoney> findleaveb(String id) {
		String hql = "from Leavebmoney as s where s.staffint='" + id
				+ "' order by did desc";
		@SuppressWarnings("unchecked")
		List<Leavebmoney> m = super.findAll(hql);
		List<Leavebmoney> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
				 //list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
		return list;
	}

	/**
	 * 查询税前工资
	 * 
	 * @param id
	 * @return
	 */
	public List<Dutymoney> finddutymoney(String id) {
		String hql = "from Dutymoney as s where s.staffint='" + id
				+ "' order by did desc";
		@SuppressWarnings("unchecked")
		List<Dutymoney> m = super.findAll(hql);
		List<Dutymoney> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
			//	list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
		return list;
		 
	}

	/**
	 * 查询税前扣除
	 * 
	 * @param id
	 * @return
	 */
	public List<Dutydeduct> finddutydeduct(String id) {
		String hql = "from Dutydeduct as s where s.staffint='" + id
				+ "' order by did desc";
		@SuppressWarnings("unchecked")
		List<Dutydeduct> m = super.findAll(hql);
		List<Dutydeduct> list=null ;
		try {
			if(m.size()>0){
			 //list=m; 
				 list=CryptUtils.decryptNew(m);
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
		return list;
	}

	/**
	 * 查询税前应发工资
	 * 
	 * @param id
	 * @return
	 */
	public List<Dutysendmoney> finddutysend(String id) {
		String hql = "from Dutysendmoney as s where s.staffint='" + id
				+ "' order by did desc";
		@SuppressWarnings("unchecked")
		List<Dutysendmoney> m = super.findAll(hql);
		List<Dutysendmoney> list=null ;
		try {
			if(m.size()>0){
				  list=CryptUtils.decryptNew(m);
		 // list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	/***
	 * 查询工会费
	 * 
	 * @param id
	 * @return
	 */
	public List<Tradecost> findtradecost(String id) {
		String hql = "from Tradecost as s where s.staffint='" + id
				+ "' order by did desc";
		@SuppressWarnings("unchecked")
		List<Tradecost> m = super.findAll(hql);
		List<Tradecost> list=null ;
		try {
			if(m.size()>0){
				  list=CryptUtils.decryptNew(m);
		     //list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}
	 
	/***
	 * 查询税后饭贴
	 */
	public List<Dutyback> finddutyback(String id) {
		String hql = "from Dutyback as s where s.staffint='" + id
				+ "' order by did desc";
		@SuppressWarnings("unchecked")
		List<Dutyback> m = super.findAll(hql);
		List<Dutyback> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
				//list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}
	/***
	 * 查询税后饭贴
	 */
	public List<Dutyback> finddutyback(String id,String date) {
		String hql = "from Dutyback   s where s.staffint='" + id
				+ "' and s.datemoney='"+date+"'";
		@SuppressWarnings("unchecked")
		List<Dutyback> m = super.findAll(hql);
		List<Dutyback> list=null ;
		try {
			if(m.size()>0){
		      list=CryptUtils.decryptNew(m);
				//list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}
	/***
	 * 查询税后应发合计
	 * 
	 * @param id
	 * @return
	 */
	public List<Dutycount> finddutycount(String id) {
		String hql = "from Dutycount as s where s.staffint='" + id
				+ "' order by did desc";
		@SuppressWarnings("unchecked")
		List<Dutycount> m = super.findAll(hql);
		List<Dutycount> list=null ;
		try {
			if(m.size()>0){
		    list=CryptUtils.decryptNew(m);
			//	list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	/***
	 * 查询社保
	 * 
	 * @param add
	 * @return
	 */
	public List<Companyb> findcompanyb(String add) {
		String hql = "from Companyb as s  where   s.nature='" + add + "'";
		@SuppressWarnings("unchecked")
		List<Companyb> m = super.findAll(hql);
		return m;
	}

	// =====================================================================
	/***
	 * 查询 补发工资
	 * 
	 * @param add
	 * @return
	 */
	public List<Bfsalary> findbfsalary(String add, String posid) {
		String hql = "from Bfsalary as s  where   s.staffint='" + add
				+ "' and s.datemoney='" + posid + "'";
		@SuppressWarnings("unchecked")
		List<Bfsalary> m = super.findAll(hql);
		List<Bfsalary> list=null;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	/***
	 * 查询 晋升 工资
	 * 
	 * @param add
	 * @return
	 */
	public List<Jsbfmoney> findjsbfmoney(String add, String posid) {
		String hql = "from Jsbfmoney as s  where   s.staffint='" + add
				+ "' and s.datemoney='" + posid + "'";
		@SuppressWarnings("unchecked")
		List<Jsbfmoney> m = super.findAll(hql);
		List<Jsbfmoney> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;

	}

	/***
	 * 查询工资调整
	 * 
	 * @param add
	 * @param poid
	 * @return
	 */
	public List<Moneyadjust> findmoneyadjust(String add, String poid) {
		String hql = "from Moneyadjust as s  where   s.staffint='" + add
				+ "' and s.datemoney='" + poid + "'";
		@SuppressWarnings("unchecked")
		List<Moneyadjust> m = super.findAll(hql);
		List<Moneyadjust> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	/***
	 * 加班工资
	 * 
	 * @param add
	 * @param poid
	 * @return
	 */
	public List<Overtimemoney> findovertimemoney(String add, String poid) {
		String hql = "from Overtimemoney as s  where   s.staffint='" + add
				+ "' and s.datemoney='" + poid + "'";
		@SuppressWarnings("unchecked")
		List<Overtimemoney> m = super.findAll(hql);
		List<Overtimemoney> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	/***
	 * 加班餐贴
	 * 
	 * @param add
	 * @param poid
	 * @return
	 */
	public List<Overtimemeals> findovertimemeals(String add, String poid) {
		String hql = "from Overtimemeals as s  where   s.staffint='" + add
				+ "' and s.datemoney='" + poid + "'";
		@SuppressWarnings("unchecked")
		List<Overtimemeals> m = super.findAll(hql);
		List<Overtimemeals> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	/***
	 * 轮班餐贴
	 * 
	 * @param add
	 * @param poid
	 * @return
	 */
	public List<Shiftallowance> findshiftallowance(String add, String poid) {
		String hql = "from Shiftallowance as s  where   s.staffint='" + add
				+ "' and s.datemoney='" + poid + "'";
		@SuppressWarnings("unchecked")
		List<Shiftallowance> m = super.findAll(hql);
		List<Shiftallowance> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	/***
	 * 忠诚奖
	 * 
	 * @param add
	 * @param poid
	 * @return
	 */
	public List<Loyalward> findloyalward(String add, String poid) {
		String hql = "from Loyalward as s  where   s.staffint='" + add
				+ "' and s.datemoney='" + poid + "'";
		@SuppressWarnings("unchecked")
		List<Loyalward> m = super.findAll(hql);
		List<Loyalward> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	// ============================================================
	public List<Solidmoney> findsalarydetail(String sql, Page page) {
		ContextContainer.setPage(page);
		List<Solidmoney> m = super.getListPage(sql);
		List<Solidmoney> list=null ;
		try {
			if(m.size()>0){
		     list=CryptUtils.decryptNew(m);
			//	list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	public List<Solidmoney> findcountmoney(String id, String date) {
		String hql = "from Solidmoney as s  where   s.staffint='" + id
				+ "' and s.datemoney='" + date + "'";
		@SuppressWarnings("unchecked")
		List<Solidmoney> m = super.findAll(hql);
		List<Solidmoney> list=null;
		try {
			if(m.size()>0){
		    list=CryptUtils.decryptNew(m);
				//list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	/***
	 * 查询税后应发合计
	 * 
	 * @param id
	 * @return
	 */
	public List<Dutycount> findcount(String id, String date) {
		String hql = "from Dutycount as s where s.staffint='" + id
				+ "' and s.datemoney='" + date + "'";
		@SuppressWarnings("unchecked")
		List<Dutycount> m = super.findAll(hql);
		List<Dutycount> list=null ;
		try {
			if(m.size()>0){
		    list=CryptUtils.decryptNew(m);
		    //	list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}

	/**
	 * 查询税前工资
	 * 
	 * @param id
	 * @return
	 */
	public List<Dutymoney> findymoney(String id, String date) {
		String hql = "from Dutymoney as s where s.staffint='" + id
				+ "' and s.datemoney='" + date + "'";
		@SuppressWarnings("unchecked")
		List<Dutymoney> m = super.findAll(hql);
		List<Dutymoney> list=null ;
		try {
			if(m.size()>0){
		       list=CryptUtils.decryptNew(m);
		    //list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}
	/**
	 * 查询税前应发工资
	 * 
	 * @param id
	 * @return
	 */
	public Dutysendmoney finddutysend(String id,String date) {
		String hql = "from Dutysendmoney as s where s.staffint='" + id
				+ "'  and s.datemoney='" + date + "'";
		Dutysendmoney dbResult = (Dutysendmoney) wsHibernateDaoSupportProxy
				.uniqueResult(hql);
		Dutysendmoney dutysendmoney=new Dutysendmoney();
		if(dbResult!=null){
			 try {
				dutysendmoney=CryptUtils.decryptNew(dbResult);
				// dutysendmoney=dbResult;
			} catch (Exception e) {
				e.printStackTrace();
			}
			 return dutysendmoney;
		}else{
			return dbResult;
		}
		
	}
	/**
	 * 查询请假扣款
	 * 
	 * @param id
	 * @return
	 */
	public Leavebmoney findleaveb(String id,String date) {
		String hql = "from Leavebmoney as s where s.staffint='" + id
				+ "'and s.datemoney='" + date + "'";
		Leavebmoney dbResult = (Leavebmoney) wsHibernateDaoSupportProxy
				.uniqueResult(hql);
		Leavebmoney leavebmoney=new Leavebmoney();
		if(dbResult!=null){
			 try {
				leavebmoney=CryptUtils.decryptNew(dbResult);
				 // leavebmoney=dbResult;
			} catch (Exception e) {
				e.printStackTrace();
			}
			 return leavebmoney;
		}else{
			return dbResult;
		}
	}
	/**
	 * 查询税前扣除
	 * 
	 * @param id
	 * @return
	 */
	public List<Dutydeduct> finddeduct(String id, String date) {
		String hql = "from Dutydeduct as s where s.staffint='" + id
				+ "' and s.datemoney='" + date + "'";
		@SuppressWarnings("unchecked")
		List<Dutydeduct> m = super.findAll(hql);
		List<Dutydeduct> list=null;
		try {
			if(m.size()>0){
		   list=CryptUtils.decryptNew(m);
		   ///	list=m;
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}
	/**
	 * 查询派遣员工管理费
	 * @param id
	 * @param date
	 * @return
	 */
public List<Dispatchmanger> finddispatchmanger(String id, String date){
	String hql = "from Dispatchmanger as s where s.staffint='" + id
			+ "' and s.datemoney='" + date + "'";
	@SuppressWarnings("unchecked")
	List<Dispatchmanger> m = super.findAll(hql);
	List<Dispatchmanger> list=null;
	try {
		if(m.size()>0){
// list=m;
	  list=CryptUtils.decryptNew(m);
		}else{
			return m;
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	 
	return list;
	}
	/**
	 * 查询个人所得税
	 * 
	 * @param id
	 * @param date
	 * @return
	 */
	public List<Personalduty> finddutyper(String id, String date) {
		String hql = "from Personalduty as s where s.staffint='" + id
				+ "' and s.datemoney='" + date + "'";
		@SuppressWarnings("unchecked")
		List<Personalduty> m = super.findAll(hql);
		List<Personalduty> list=null ;
		try {
			if(m.size()>0){
//  list=m;
		  list=CryptUtils.decryptNew(m);
			}else{
				return m;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		 
		return list;
	}
	
	public Tradecost findtradecost(String id,String date){
		String hql = "from Tradecost as s where s.staffint='" + id
				+ "' and s.datemoney='" + date + "'";
		Tradecost dbResult = (Tradecost) wsHibernateDaoSupportProxy
				.uniqueResult(hql);
		Tradecost tradecost=new Tradecost();
		if(dbResult!=null){
			 try {
				tradecost=CryptUtils.decryptNew(dbResult);
				 /// tradecost=dbResult;
			} catch (Exception e) {
				e.printStackTrace();
			}
			 return tradecost;
		}else{
			return dbResult;
		}
	}
	
//查询个人所得税
	public Personalduty findger(String id, String date) {
		String hql = "from Personalduty as s where s.staffint='" + id
				+ "' and s.datemoney='" + date + "'";
		Personalduty dbResult = (Personalduty) wsHibernateDaoSupportProxy.uniqueResult(hql);
		Personalduty tradecost=new Personalduty();
		if(dbResult!=null){
			 try {
				 tradecost=CryptUtils.decryptNew(dbResult);
				// tradecost=dbResult;
				 } catch (Exception e) {
				e.printStackTrace();
			}
			 return tradecost;
		}else{
			return dbResult;
		}
	}

	/***
	 * 查询社保调整
	 * 
	 * @return
	 */
	public SalSocialAdjust findsalsoialadjust(String id, String idcar) {
		String hql = "from SalSocialAdjust as s where s.staffint='" + id
				+ "' and s.period='"+idcar+"'  and isDelete='"+SalConstant.NOT_DELETE+"' ";
		SalSocialAdjust dbResult = (SalSocialAdjust) wsHibernateDaoSupportProxy
				.uniqueResult(hql);
		SalSocialAdjust tradecost=new SalSocialAdjust();
		if(dbResult!=null){
			 try {
				 tradecost=CryptUtils.decryptNew(dbResult);
			} catch (Exception e) {
				e.printStackTrace();
			}
			 return tradecost;
		}else{
			return dbResult;
		}
	}
	
	

	/***
	 * 查询最低工资
	 * 
	 * @param id
	 * @param idcar
	 * @return
	 */
	public MinMoney findminmoney(String id,String date) {
		String hql = "from MinMoney as s where s.staffint='" + id + "' and s.datemoney='"+date+"'";
		MinMoney dbResult = (MinMoney) wsHibernateDaoSupportProxy
				.uniqueResult(hql);
		MinMoney tradecost=new MinMoney();
		if(dbResult!=null){
			 try {
			  tradecost=CryptUtils.decryptNew(dbResult);
				// tradecost = dbResult;
			} catch (Exception e) {
				e.printStackTrace();
			}
			 return tradecost;
		}else{
			return dbResult;
		}
	}
	
	public Miniwase findminiwase(String id){
		String hql = "from Miniwase as s where s.engtype='" + id + "' and isDelete='"+SalConstant.NOT_DELETE+"' ";
		Miniwase dbResult = (Miniwase) wsHibernateDaoSupportProxy
					.uniqueResult(hql);
		return dbResult;
	}
	
	/**
	 * 薪资数据查询 
	 * */
	public SalSalaryData findSalaryData(String id,String date){
		String hql = " from SalSalaryData s where s.staffint='"+id+"' and s.period='"+date+"' and s.isDelete='0' ";
		 List<SalSalaryData> salarys =  super.findAll(hql);
		 SalSalaryData salary = null;
		 if(null==salarys || salarys.size()==0){
			 return null;
		 }
		 try{
			 salary = CryptUtils.decryptNew(salarys.get(0));
			 
			 
		 }catch(Exception e){
			 e.printStackTrace(System.out);
		 }
		 
		 return salary;
	}
	
}



